package com.game;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.view.MotionEvent;

public class Scene5 extends Scene {

	private Bitmap m_Background;
	private boolean m_bWonScene;
	private InfoBox m_InfoBox;
	private ButtonOneTouch m_DebugWinButton;
	
	public Scene5(SceneManager parent)
	{
		super(parent);
		m_Background = LoadBitmap(R.drawable.scene5_ejemplo);
		
		m_bWonScene = false;
		ButtonOneTouch infobutton = new ButtonOneTouch(0, 80, 50, LoadBitmap(R.drawable.scene5_info)); 
		m_InfoBox = new InfoBox(LoadBitmap(R.drawable.general_opacity), infobutton);
		
		m_DebugWinButton = new ButtonOneTouch(0, 10, 10, LoadBitmap(R.drawable.scene5_button_win));
	}
	
	@Override
	public void Draw(Canvas canvas) 
	{
		canvas.drawBitmap(m_Background, 0, 0, null);
		
		m_DebugWinButton.Draw(canvas);
		
		if(m_bWonScene)
		{
			m_InfoBox.Draw(canvas);
		}
		

	}

	@Override
	public void End() {
		// TODO Auto-generated method stub

	}

	@Override
	public void Start() {
		// TODO Auto-generated method stub

	}

	@Override
	public void Update() 
	{
		if(m_DebugWinButton.Used())
		{
			m_bWonScene = true;
		}

	}

	@Override
	public boolean handleTouch(MotionEvent event) {
		synchronized (mSurfaceHolder) 
		{
			int tx,ty;
			tx = (int)event.getX();
			ty = (int)event.getY();			
			
			if(m_bWonScene)
			{
				if(m_InfoBox.HandleTouch(tx, ty))
				{
					mParentSM.ChangeScene(new Scene4(mParentSM,0)); // HACK : To change to actual planet
				}
			}
			else
			{
				m_DebugWinButton.TryTouch(tx, ty);
			}
			
			
		}
		return true;
	}

}
